package com.syncshot.androidapp.viewholders;

import android.content.res.Resources;
import android.widget.ImageView;
import android.widget.TextView;

import com.syncshot.androidapp.R;
import com.syncshot.androidapp.adapters.AbstractViewHolder;
import com.syncshot.androidapp.helper.ImageDownloader;
import com.syncshot.androidapp.model.User;

public class UsersViewHolder extends AbstractViewHolder<User>{
	
	private ImageView mImageView;
	private TextView mTextView;

	@Override
	public void setContent(Resources res, int position, User content) {
		
		ImageDownloader downloader = new ImageDownloader(null);
		if(content.getUrl() != null){
			downloader.download(content.getUrl(), getImageView());
		}
		getTextView().setText(content.getName());
		
	}
	
	
	private ImageView getImageView(){
		if(mImageView == null){
			mImageView = (ImageView) findViewById(R.id.userImageView);
		}
		
		return mImageView;
	}
	
	private TextView getTextView(){
		if(mTextView == null){
			mTextView = (TextView) findViewById(R.id.nickNameTextView);
			mTextView = (TextView) findViewById(R.id.nickNameTextView);
		}
		
		return mTextView;
	}
	

}
